package indi.jp.project.center.controller;

import indi.jp.project.center.service.CenterService;
import indi.jp.project.core.entity.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

/**
 * 中心总控
 *
 * @author jiangping
 * @date 2021/11/25
 */
@RestController
@RequestMapping("/center")
public class CenterController {

    @Autowired
    private CenterService centerService;

    @GetMapping("/queryCenterData")
    public JsonResult queryCenterData(HttpServletRequest request){
        Map<String, Object> params = new HashMap<>();
        String account = request.getParameter("account");
        params.put("lander", account);
        try {
            Map<String, Integer> map = centerService.queryCenterData(params);
            return JsonResult.success(map);
        } catch (SQLException e) {
            e.printStackTrace();
            return JsonResult.error();
        }
    }

}
